package com.yt.system.dao;

import com.yt.system.domain.Privilege;
import com.yt.system.domain.Role;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface RoleMapper {
    int deleteByPrimaryKey(Integer roid);

    int insert(Role record);

    int insertSelective(Role record);

    @Select("select * from role where roid = #{roid}")
    Role selectByPrimaryKey(Integer roid);

    int updateByPrimaryKeySelective(Role record);

    int updateByPrimaryKey(Role record);

    @Select("select * from role where roid = (select roid from user_role where aid = #{aid})")
    Role selectByAid(Integer aid);

    @Update("update role set menu=#{menu}, permission = #{permission} where roid = #{roid} ")
    int updateRolePemission(Integer roid, String menu, String permission);  //权限分配

    @Select("select * from role")
    List<Role> selectAllRole();  //查询所有角色

    @Update("update role set rolename=#{rolename},content=#{content},updatetime=#{updatetime} where roid = #{roid}")
    int updateRole(Integer roid, String rolename, String content,Date updatetime);  //修改角色信息

    @Select("select * from role where rolename like #{str} or content like #{str}")
    List<Role> selectLikeNameOrContent(String str);  //根据角色名和描述进行查询

}